package com.zzyl.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.zzyl.base.PageResponse;
import com.zzyl.base.ResponseResult;
import com.zzyl.entity.NursePlan;
import com.zzyl.entity.NursingProject;
import com.zzyl.mapper.NursingProjectMapper;
import com.zzyl.service.NursingProjectService;
import com.zzyl.vo.NursingProjectVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class NursingProjectServiceImpl implements NursingProjectService {
     @Autowired
     private NursingProjectMapper nursingProjectMapper;

     @Override
     public void updateProject(NursingProject nursingProject) {
               nursingProjectMapper.update(nursingProject);
     }

     @Override
     public void choiceProject(Integer id, Integer status) {
               nursingProjectMapper.choice(id,status);
     }

     @Override
     public PageResponse<NursingProjectVo> findByPage(String name, Integer status, Integer pageNum, Integer pageSize) {
          //分页
          PageHelper.startPage(pageNum,pageSize);
          //操作数据库
          List<NursingProject> list = nursingProjectMapper.selectByPage(name,status);
          //转Page类型
          Page page = (Page) list;
          //转成Vo类型
          PageResponse<NursingProjectVo> response = PageResponse.of(page, NursingProjectVo.class);
          return response;
     }

     @Override
     public void addProject(NursingProject nursingProject) {
          nursingProjectMapper.add(nursingProject);
     }

     @Override
     public NursingProjectVo selectById(Integer id) {
          NursingProjectVo nursingProjectVo = nursingProjectMapper.selectById(id);
          return nursingProjectVo;
     }

     @Override
     public void deleteProject(Integer id) {
          nursingProjectMapper.delete(id);
     }

     @Override
     public List<NursingProjectVo> selectAll() {
          //获取所有计划
          List<NursingProjectVo> list = nursingProjectMapper.selectAll();
          return list;
     }
}
